<!--
  To change this template, choose Tools | Templates
  and open the template in the editor.
-->

<%@ page contentType="text/html;charset=UTF-8" %>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="save_undo" />
        <title>Add an employee to the project</title>
    </head>
    <body>
       <div class="undernav">
           <!-- This is the help button. -->
            <%  def help = Help.findByNameAndLanguage("project_add_employee", session.language)
            def helplink = createLink(action:'show', controller:'help', id: help?.id )%>
            <a href="#" class="menulink" onClick="MyWindow=window.open('${helplink}','Help','width=350,height=450'); return false;">${Inter.printOut('Help',session.language)}</a>
            <!-- This is the end of the help button. -->
       </div>
        <div class="body">

           <!-- <div class="mode">
              <span style="font-weight:bold; padding-right:10px">
              <g:if test="${session.mode == null || session.mode.equalsIgnoreCase('sandbox')}">
                Sandbox mode
                <g:btnSaveUndo currentView="add_employee" currentController="project" idProject="${projectid}" />
              </g:if>
              <g:else>
                Budget mode
              </g:else>
                </span>
            </div> -->

          <h1>${Inter.printOut('Add Employee to Project',session.language)}: <%
          def name
          def area
        if(DBConnection.isConnectionStarted()){
            name = DBConnection.getProject(projectid).getName();
            area = DBConnection.getProject(projectid).getArea().getName();
          }else{
            name = Project.get(projectid).getName();
            area = Project.get(projectid).getArea()?.getName();
          } %>
          ${name}</h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <form name ="addEmployee" action="/MegaSoft/project/save_added_employee" >
              <input type="hidden" name="projectid" value="${projectid}"/>
              <g:if test="${employeeList.size()<=0}">
                  <div class="message">no more employees to add</div>
                </g:if>
                <g:else>
              <table>
                <thead>
                    <tr>
                        <th>${Inter.printOut('Add',session.language)}</th>
                        <g:sortableColumn property="name" title="${Inter.printOut('Name',session.language)}" />
                        <g:sortableColumn property="title" title="${Inter.printOut('Title',session.language)}" />
                        <th>${Inter.printOut('Hired by area',session.language)}</th>
                    </tr>
                </thead>
                <tbody>
                    <g:each in="${employeeList}" status="i" var="employeeInstance">
                      <tr>
                        <td>
                          <g:if test="${(session.mode && session.mode.equalsIgnoreCase('budget') && !employeeInstance.isWorkingOverTime()) || !session.mode || session.mode.equalsIgnoreCase('sandbox')}">
                            <input type="checkbox" name ="employeeid" value="${employeeInstance.id}" />
                          </g:if>
                        </td>
                        <td>
                          ${fieldValue(bean:employeeInstance, field:'firstName')}
                          ${fieldValue(bean:employeeInstance, field:'lastName')}
                        <g:if test="${!((session.mode && session.mode.equalsIgnoreCase('budget') && !employeeInstance.isWorkingOverTime()) || !session.mode || session.mode.equalsIgnoreCase('sandbox'))}">
                        (overbooked)
                        </g:if>
                        </td>
                        <td>
                         ${fieldValue(bean:employeeInstance, field:'title')}
                        </td>
                        <td>
                          <g:if test="${employeeInstance.hiredBy?.name != area}">
                            <img src="" title="Cross" alt="Cross">
                          </g:if>
                          <g:else>
                            <img src="" title="Tick" alt="Tick">
                          </g:else>
                        </td>
                      </tr>
                    </g:each>
                </tbody>
              </table>
                  
              <div class="buttons">
                  <span class="button">
                      <input type="submit" class="add_employee" value="${Inter.printOut('Add Employee',session.language)}" name="Add employee"/>
                  </span>
             </div>
                  </g:else>
            </form>
        </div>
  </body>
</html>
